home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / atibgi.zip / ATIVW256.C < prev    next >
Text File  |  1990-05-27  |  3KB  |  131 lines

  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include <dos.h>
  4.  
  5.  
  6. /*
  7. This a standard autodetect function as outlines in the Turbo C Manual.
  8. If the card is detected, the highest available mode number is returned.
  9. Otherwise a negative number indicating an error is returned.
  10.  
  11.  
  12. copyright(c) 1990 by Peter F. Jones. ALL RIGHTS RESERVED.
  13. This software may be used and included in other programs as
  14. outlined in your software license.
  15. */
  16.  
  17. char   copyright1[] = "copyright(c) 1990 by Peter F. Jones. ALL RIGHTS RESERVED.";
  18.  
  19.  
  20. unsigned char test_bios_mode(unsigned char bios_mode)
  21.   {
  22.     _AL = bios_mode;
  23.                    /* al has desired mode on input           */
  24.                    /* on return ax = 0xffff if not supported */
  25.     asm       push      bp
  26.     asm       mov       bp,sp
  27.         asm       push      es
  28.         asm       mov       ah,12h
  29.         asm       mov       bx,5506h
  30.         asm       mov       bp,0ffffh
  31.         asm       int       10h
  32.         asm       mov       ax,bp
  33.         asm       pop       es
  34.     asm       pop       bp
  35.     if (_AX==0xffff)
  36.            return(0);
  37.          else
  38.            return(1);
  39.  
  40.   };
  41.  
  42.  
  43.  
  44.  
  45. unsigned char test_512K_memory(void)
  46.     {
  47.     asm      push es         /* save registers es and bx                   */
  48.     asm      push bx
  49.     asm      mov  ax,0c000h  /*define storage location of EXTENDED_REG     */
  50.         asm      mov  es,ax
  51.         asm      mov  bx,010h
  52.         asm      mov  dx,es:[bx] /*get the value of EXTENDED_REG from contents */
  53.                  /*;of the storage location C000:0010h         */
  54.         asm      pop  bx         /*;restore registers es and bx                */
  55.         asm      pop  es
  56.  
  57.         asm       cli
  58.                  /*  dx has EXTENDED_REG */
  59.         asm       mov       al,0bbh
  60.         asm       out       dx,al
  61.         asm       inc       dx
  62.         asm       in        al,dx
  63.         asm       sti
  64.     asm       and       al,020h
  65.  
  66.  
  67.                   /*     al = 0  ; 256K display memory installed   */
  68.                   /*        = 20h; 512K display memory installed   */
  69.  
  70.     if (_AL==0x20)
  71.            return(1);
  72.          else
  73.            return(0);
  74.  
  75.  
  76. };
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. int huge detect_ATI_VGA_Wonder()
  84.     {
  85.      int   counter;
  86.      char  manufacturer_id[] = "761295520";
  87.      char  chip_set_id[] =     "31";
  88.      char far  *manufacturer;
  89.      char far  *chip_set;
  90.      unsigned char  found;
  91.  
  92.     found = 1;
  93.     manufacturer = MK_FP(0xC000,0x0031);
  94.     chip_set     = MK_FP(0xC000,0x0040);
  95.  
  96.     for(counter=0;counter<9;counter++)
  97.       if (manufacturer[counter]!=manufacturer_id[counter]) found = 0;
  98.  
  99.     if (found)
  100.     for(counter=0;counter<2;counter++)
  101.       if (chip_set[counter]!=chip_set_id[counter]) found = 0;
  102.  
  103.       if (!found) return(-11);    /* graphics error - no ATI Wonder */
  104.  
  105.  
  106.       if (test_512K_memory())   /*if 512k then try hires modes*/
  107.      {
  108.          if (test_bios_mode(0x63))  /*check 800x600*/
  109.           {
  110.              return(3);
  111.           };
  112.  
  113.          if (test_bios_mode(0x62))  /*check 640x480*/
  114.          {
  115.              return(2);
  116.           };
  117.      };
  118.  
  119.          if (test_bios_mode(0x61))  /*check 640x400*/
  120.           {
  121.              return(1);
  122.           };
  123.  
  124.          if (test_bios_mode(0x13))   /*check 320x200*/
  125.           {
  126.              return(0);
  127.           };
  128.        };
  129.  
  130.  
  131.